import javax.microedition.lcdui.Graphics;

public class RecordeCanvas extends DanceGameScreen{
	private ScrollableTable table;
	private Recorde[] listaRecorde;
	private static RecordeCanvas singleton;
	
	private RecordeCanvas() {
		this.listaRecorde = new Recorde[]{
				new Recorde("MAR",1000),
				new Recorde("OPA",500),
				new Recorde("DEI",400),
				new Recorde("SDA",300),
				new Recorde("BLA",150),
				new Recorde("CAR",120),
				new Recorde("ISS",90),
				new Recorde("WTF",80),
		};
		
		this.table = new ScrollableTable(getRecordeData(), getWidth() - 20, getHeight() - 20);
	}

	public static RecordeCanvas getInstance(){
		if(singleton == null){
			singleton = new RecordeCanvas();
		}
		return singleton;
	}
	
	private String[][] getRecordeData(){
		String recordes[][] = new String[this.listaRecorde.length][1];
		
		for(int i = 0; i < recordes.length; i++){
			recordes[i][0] = this.listaRecorde[i].toString();
		}
		
		return recordes; 
	}
	
	public void keyPressed(int key) {
		int keyCode = getGameAction(key);
		table.keyPressed(keyCode);	
		repaint();
	}
	
	public void paint(Graphics g){
		g.setColor(0xffffff);
		
		g.fillRect(0, 0, getWidth(), getHeight());
		
		g.translate(10, 10);
		
		table.paint(g);
		
		g.translate(-10, -10);
	}
	
	public void init(){
		this.addCommand(Constants.selectCommand);
		this.addCommand(Constants.backCommand);
	}
	
	public ScrollableTable getTable() {
		return table;
	}

	public void setTable(ScrollableTable table) {
		this.table = table;
	}

	public Recorde[] getListaRecorde() {
		return listaRecorde;
	}

	public void setListaRecorde(Recorde[] listaRecorde) {
		this.listaRecorde = listaRecorde;
	}
}
